﻿namespace WLFramework.Web
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Web;
    using WLFramework.Web.Binder.ValueProvider;
    
    public static class HttpRequestExtensions
    {
        public static HttpPostedFile GetHttpPostedFile(this HttpRequest request, string key)
        {
            HttpFileCollectionValueProvider provider = new HttpFileCollectionValueProvider(request.Files);
            return provider.GetValue(key).RawValue as HttpPostedFile;
        }

#if Net40
        public static HttpPostedFileBase GetHttpPostedFile(this HttpRequestBase request, string key)
        {
            HttpFileBaseCollectionValueProvider provider = 
                new HttpFileBaseCollectionValueProvider(request.Files);
            return provider.GetValue(key).RawValue as HttpPostedFileBase;
        }
#endif
    }
}
